package com.gdth.bank.adapter;

import java.util.List;

import com.gdth.bank.R;
import com.gdth.bank.bean.DbjjItem;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.webkit.WebView.FindListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class DbJjDjListAdapter extends BaseAdapter{
	protected Context context;  

 	protected List<DbjjItem> vList;
 
 	protected String filepath ;
 	protected int layout;
	
 	public DbJjDjListAdapter(Context context, List<DbjjItem> vList){
 		this.context = context;
        this.vList = vList;
        this.layout = R.layout.item_dbjjdj;
 	}
 	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return vList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final DbjjItem model = vList.get(position);
		final int positions=position;
		ViewHolder holder = null;
		if (convertView == null){
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(layout, null);
			holder.local_bh_txt = (TextView) convertView.findViewById(R.id.dbjj_bh_txt);
			holder.local_ywxq=(Button) convertView.findViewById(R.id.dbjj_ti_button);
			holder.local_fqkssj_txt = (TextView) convertView.findViewById(R.id.dbjj_fqkssj_txt);
		    holder.local_fqr_txt = (TextView) convertView.findViewById(R.id.dbjj_fqr_txt);
		    holder.local_zhblr_txt = (TextView) convertView.findViewById(R.id.dbjj_zhblr_txt);
//		    holder.local_slzt_txt = (TextView) convertView.findViewById(R.id.dbjj_slzt_txt);
//		    holder.local_spzt_txt = (TextView) convertView.findViewById(R.id.dbjj_spzt_txt);
		    holder.local_zhblsj_txt = (TextView) convertView.findViewById(R.id.dbjj_zhblsj_txt);
//		    holder.local_spyj_txt=(TextView)convertView.findViewById(R.id.dbjj_spyj_txt);
		    holder.local_lczt_txt=(TextView)convertView.findViewById(R.id.dbjj_lczt_txt);
		    holder.local_sc =(Button) convertView.findViewById(R.id.dbjj_sc_button);
		    holder.local_gw = (TextView) convertView.findViewById(R.id.dbjj_gw);
		    holder.local_gw_txt=(TextView)convertView.findViewById(R.id.dbjj_gw_txt);
		    holder.local_fqjssj=(TextView)convertView.findViewById(R.id.dbjj_fqjssj);
		    holder.local_fqjssj_txt =(TextView) convertView.findViewById(R.id.dbjj_fqjssj_txt);
		    holder.local_jjrmc_txt = (TextView) convertView.findViewById(R.id.dbjj_jjrmc_txt);
		    holder.local_jsrmc_txt = (TextView) convertView.findViewById(R.id.dbjj_jsrmc_txt);
		    if (this.mOnCjjlDetailClickListener != null) {
		    	holder.local_ywxq.setOnClickListener(new OnClickListener(){

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						mOnCjjlDetailClickListener.clickListener(positions);
					}
		    		
		    	});
		    }
		    if(this.mOnDeleteDetailClickListener!=null){
		    	holder.local_sc.setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if(model.getDeletebz()==1){
						mOnDeleteDetailClickListener.deleteclickListener(positions);}
					}
				});
		    }
			convertView.setTag(holder);
        }
		
		else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (holder != null){
		holder.local_bh_txt.setText(model.getId()+"");
		holder.local_fqkssj_txt.setText(model.getJssj());
		holder.local_fqjssj_txt.setText(model.getJjsj().toString());
		holder.local_gw_txt.setText(model.getGw().toString());
		holder.local_fqr_txt.setText(model.getFqrMc().toString());
		holder.local_zhblr_txt.setText(model.getZhblr().toString());
		holder.local_jsrmc_txt.setText(model.getJsrmc().toString());
		holder.local_jjrmc_txt.setText(model.getJjrmc().toString());
//		holder.local_slzt_txt.setText(model.getSlzt()+"");
//		if(!model.getSpyj().equals("")){
//			holder.local_spyj_txt.setText(model.getSpyj());
//		}
		if(model.getDeletebz()==1){
			holder.local_sc.setText("删除");
		}else{
			holder.local_sc.setText("");
			holder.local_sc.setVisibility(View.GONE);
		}
		
		String str;
//		if(model.getSpzt()==0){
//			str="申请中";
//			holder.local_spzt_txt.setText(str);
//		}else if(model.getSpzt()==1){
//			str="同意";
//			holder.local_spzt_txt.setText(str);
//		}else if(model.getSpzt()==2){
//			str="不同意";
//			holder.local_spzt_txt.setText(str);
//		}
//		if(model.getSlzt() ==2){
//			str="接收人";
//			holder.local_slzt_txt.setText(str);
//		}else if(model.getSlzt() ==3){
//			str="监管人";
//			holder.local_slzt_txt.setText(str);
//		}else if(model.getSlzt() ==0){
//			str="办理成功";
//			holder.local_slzt_txt.setText(str);
//		}else if(model.getSlzt() ==1){
//			str="申请人";
//			holder.local_slzt_txt.setText(str);
//		}
		if(model.getLcZt()==2){
			str="接收人待确认";
			holder.local_lczt_txt.setText(str);
		}else if(model.getLcZt()==3){
			str="监交人待确认";
			holder.local_lczt_txt.setText(str);
		}else if(model.getLcZt()==1){
			str="交出人待修改";
			holder.local_lczt_txt.setText(str);
		}else if(model.getLcZt()==0){
			str="流程结束";
			holder.local_lczt_txt.setText(str);
		}
		    
		
		holder.local_zhblsj_txt.setText(model.getZhblsj().toString());
	}
        return convertView;
	
	}
	public static class ViewHolder{
		public TextView local_bh=null;
		public TextView local_bh_txt=null;
		public TextView local_fqkssj=null;
		public TextView local_fqkssj_txt=null;
		public TextView local_fqr=null;
		public TextView local_fqr_txt=null;
		public TextView local_zhblr=null;
		public TextView local_zhblr_txt=null;
		public TextView local_slzt=null;
		public TextView local_slzt_txt = null;
		public TextView local_spzt = null;
		public TextView local_spzt_txt = null;
		public TextView local_zhblsj = null;
		public TextView local_zhblsj_txt = null;
		public TextView local_spyj=null;
		public TextView local_spyj_txt=null;
		public Button local_ywxq=null;
		public TextView local_lczt=null;
		public TextView local_lczt_txt=null;
		public Button local_sc=null;
		public TextView local_gw=null;
		public TextView local_gw_txt=null;
		public TextView local_fqjssj=null;
		public TextView local_fqjssj_txt=null;
		public TextView local_jsrmc_txt=null;
		public TextView local_jjrmc_txt=null;
		
				
		
	}
private OnCjjlDetailClickListener mOnCjjlDetailClickListener;
	
	public void setOnCjjlDetailClickListener(OnCjjlDetailClickListener mOnCjjlDetailClickListener) {
		this.mOnCjjlDetailClickListener = mOnCjjlDetailClickListener;
	}
	
	public interface OnCjjlDetailClickListener {
		void clickListener(int position);
	}
//删除
public OnDeleteDetailClickListener mOnDeleteDetailClickListener;
public void setOnDeleteDetailClickListener(
		OnDeleteDetailClickListener mOnDeleteDetailClickListener) {
	this.mOnDeleteDetailClickListener = mOnDeleteDetailClickListener;
}
public interface OnDeleteDetailClickListener{
	void deleteclickListener(int position);
}
}
